home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / dev / Oberon4Amiga / Dialogs / DialogInsert.Mod (.txt) < prev    next >
Oberon Text  |  1994-11-28  |  5KB  |  121 lines

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. StampElems
  4. Alloc
  5. 4 Nov 94
  6. Syntax10b.Scn.Fnt
  7. MODULE DialogInsert;
  8.     (* Markus Knasm
  9. ller 3 Aug 94 - 
  10.     IMPORT DialogFrames, DialogListBoxes, Dialogs, DialogTexts, Oberon, TextFrames, Texts;
  11.     PROCEDURE Open*; 
  12.         VAR x, y: INTEGER; panel: Dialogs.Panel; w: Texts.Writer; t: Texts.Text; o: Dialogs.Object;
  13.     BEGIN
  14.         panel := Dialogs.cmdPanel;
  15.         o := panel.NamedObject ("l");
  16.         WITH o: DialogListBoxes.Item DO
  17.             Texts.OpenWriter (w);
  18.             Texts.WriteString (w, "CheckBox"); Texts.WriteLn (w);
  19.             Texts.WriteString (w, "Button"); Texts.WriteLn (w);
  20.             Texts.WriteString (w, "StaticText"); Texts.WriteLn (w);
  21.             Texts.WriteString (w, "RadioButton"); Texts.WriteLn (w);
  22.             Texts.WriteString (w, "GroupBox"); Texts.WriteLn (w);
  23.             Texts.WriteString (w, "Text"); Texts.WriteLn (w);
  24.             Texts.WriteString (w, "Line"); Texts.WriteLn (w);
  25.             Texts.WriteString (w, "Circle"); Texts.WriteLn (w);
  26.             Texts.WriteString (w, "Rectangle"); Texts.WriteLn (w);
  27.             Texts.WriteString (w, "Slider"); Texts.WriteLn (w);
  28.             Texts.WriteString (w, "IntegerSlider"); Texts.WriteLn (w);
  29.             Texts.WriteString (w, "Clock"); Texts.WriteLn (w);
  30.             Texts.WriteString (w, "AnalogClock"); Texts.WriteLn (w);
  31.             Texts.WriteString (w, "Date"); Texts.WriteLn (w);
  32.             Texts.WriteString (w, "ColorPicker"); Texts.WriteLn (w);
  33.             Texts.WriteString (w, "ListBox"); Texts.WriteLn (w);
  34.             Texts.WriteString (w, "ComboBox"); 
  35.             t := TextFrames.Text (""); Texts.Append (t, w.buf);
  36.             o.SetMenu (t)
  37.         ELSE HALT (99)
  38.         END
  39.     END Open;
  40.     PROCEDURE ReadInt (o: Dialogs.Object; VAR x, res: INTEGER);
  41.     (* reads an integer from a dialogtext element *)
  42.         VAR t: Texts.Text; s: Texts.Scanner; 
  43.     BEGIN
  44.         WITH o: DialogTexts.Item DO 
  45.             t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s);
  46.             IF s.class = Texts.Int THEN x := SHORT (s.i); res := Dialogs.ok ELSE res := Dialogs.wrongInput END
  47.         ELSE
  48.             res := Dialogs.wrongInput
  49.         END;
  50.     END ReadInt;
  51.     PROCEDURE ReadName (o: Dialogs.Object; VAR x: ARRAY OF CHAR);
  52.     (* reads a name from the dialogtext element "name"*)
  53.         VAR t: Texts.Text; s: Texts.Scanner; 
  54.     BEGIN
  55.         WITH o: DialogTexts.Item DO
  56.             t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s);
  57.             IF s.class = Texts.Name THEN COPY (s.s, x) ELSE COPY ("", x) END
  58.         ELSE
  59.             COPY ("", x)
  60.         END
  61.     END ReadName;
  62.     PROCEDURE ReadXYWH (VAR x, y, w, h: INTEGER);
  63.     (* reads the lower left corner coordinates, wide and height from the Demo-Panel *)
  64.         VAR ox, oy, ow, oh: Dialogs.Object; i, res: INTEGER; panel: Dialogs.Panel;
  65.     BEGIN
  66.         panel := Dialogs.cmdPanel;
  67.         ox := panel.NamedObject ("x"); oy := panel.NamedObject ("y");
  68.         ow := panel.NamedObject ("w"); oh := panel.NamedObject ("h");
  69.         ReadInt (ox, i, res); IF res = 0 THEN x := i END;
  70.         ReadInt (oy, i, res); IF res = 0 THEN y := i END;
  71.         ReadInt (ow, i, res); IF res = 0 THEN w := i ELSE w := -1 END;
  72.         ReadInt (oh, i, res); IF res = 0 THEN h := i ELSE h := -1 END;
  73.     END ReadXYWH;
  74.     PROCEDURE ReadNameCmdPar (VAR name, cmd, par: ARRAY OF CHAR);
  75.         VAR on, op, oc: Dialogs.Object;
  76.     BEGIN
  77.         on := Dialogs.cmdPanel.NamedObject ("name"); oc := Dialogs.cmdPanel.NamedObject ("cmd");
  78.         op := Dialogs.cmdPanel.NamedObject ("par");
  79.         ReadName (on, name); ReadName (oc, cmd); ReadName (op, par)
  80.     END ReadNameCmdPar;
  81.     PROCEDURE Do*;
  82.         VAR 
  83.             o, last: Dialogs.Object; p: Dialogs.Panel; name, cmd, par, insert: ARRAY 64 OF CHAR;
  84.             w0: Texts.Writer; t: Texts.Text; x, y, w, h, res: INTEGER;
  85.     BEGIN
  86.         DialogFrames.GetCaretPosition (p, x, y); last:= Dialogs.lastin;
  87.         ReadXYWH (x, y, w, h);
  88.         ReadNameCmdPar (name, cmd, par); 
  89.         Texts.OpenWriter (w0); Texts.WriteString (w0, name); Texts.WriteString (w0, " ");
  90.         Texts.WriteInt (w0, x, 5); Texts.WriteInt (w0, y, 5); Texts.WriteInt (w0, w, 5); Texts.WriteInt (w0, h, 5);
  91.         t := TextFrames.Text (""); Texts.Append (t, w0.buf); 
  92.         Oberon.Par.text := t;
  93.         o := Dialogs.cmdPanel.NamedObject ("l");
  94.         WITH o: DialogListBoxes.Item DO
  95.             IF o.selline = 0 THEN insert := "DialogCheckBoxes.Insert"
  96.             ELSIF o.selline = 1 THEN insert := "DialogButtons.Insert"
  97.             ELSIF o.selline  = 2 THEN insert := "DialogStaticTexts.Insert"
  98.             ELSIF o.selline = 3 THEN insert := "DialogRadioButtons.Insert"
  99.             ELSIF o.selline = 4 THEN insert := "DialogGroupBoxes.Insert"
  100.             ELSIF o.selline = 5 THEN insert := "DialogTexts.Insert"
  101.             ELSIF o.selline = 6 THEN insert := "DialogLines.Insert"
  102.             ELSIF o.selline = 7 THEN insert := "DialogCircles.Insert"
  103.             ELSIF o.selline = 8 THEN insert := "DialogRectangles.Insert"
  104.             ELSIF o.selline = 9 THEN insert := "DialogSliders.Insert"
  105.             ELSIF o.selline = 10 THEN insert := "DialogIntegerSliders.Insert"
  106.             ELSIF o.selline = 11 THEN insert := "DialogClocks.Insert"
  107.             ELSIF o.selline = 12 THEN insert := "DialogAnalogClocks.Insert"
  108.             ELSIF o.selline = 13 THEN insert := "DialogDates.Insert"
  109.             ELSIF o.selline = 14 THEN insert := "DialogColorPickers.Insert"
  110.             ELSIF o.selline = 15 THEN insert := "DialogListBoxes.Insert"
  111.             ELSIF o.selline = 16 THEN insert := "DialogComboBoxes.Insert"
  112.             ELSE
  113.             END
  114.         ELSE
  115.         END;
  116.         Oberon.Call (insert, Oberon.Par, FALSE, res);
  117.         IF (Dialogs.lastin # last) & (par[0] # 0X) THEN Dialogs.lastin.SetPar (par) END;
  118.         IF (Dialogs.lastin # last) & (cmd[0] # 0X) THEN Dialogs.lastin.SetCmd (cmd) END;
  119.     END Do;
  120. END DialogInsert.
  121.